/*
 * File:   interrupt.c
 * Author: Marcel
 *
 * Created on 20. Juli 2012, 00:13
 */

#include <p18f2620.h>
#include "uart.h"
#include "timer.h"
#include "indicator.h"
#include "interrupt.h"

// High Interrupt Service Routine (ISR)
#pragma code high_vector=0x08
void interrupt_at_high_vector(void) {
    _asm GOTO high_isr _endasm
}

// Low Interrupt Service Routine (ISR)
#pragma code low_vector=0x18
void interrupt_at_low_vector(void) {
    _asm GOTO low_isr _endasm
}

#pragma code

#pragma interrupt high_isr

void high_isr(void) {
    if(PIR1bits.RCIF) {
        uart_isr();
        PIR1bits.RCIF = 0;
    }
    else if(INTCONbits.TMR0IF) {
        timer_isr();
        INTCONbits.TMR0IF = 0;
    }
}

#pragma interrupt low_isr
void low_isr(void) {
    if(PIR1bits.TMR2IF) {
        idctr_isr();
        PIR1bits.TMR2IF = 0;
    }
}